import React, { useState } from "react";
import axios from 'axios';
const View = () => {
    const [title, setTitle] = useState('');
    const onSubmit = (event) => {
        event.preventDefault();
        axios.post('http://posts.com/posts/create', { 'title': title });
        setTitle('');
    }
    return <div>
        <form onSubmit={onSubmit}>
            <div className="form-group">
                <label>Title</label>
                <input value={title} className="form-control" onChange={e => setTitle(e.target.value)} />
            </div>
            <div className="form-group">
                <button className="btn btn-primary">Submit</button>
            </div>
        </form>
    </div>
};

export default View;